package com.dc.refactoring._2_在对象之间搬移特性._1_MoveMethod.newObject.methodTwo;

import java.util.Random;

public class AccountType {
    public boolean isPremium() {
        return new Random().nextBoolean();
    }

    /**
     * 【2】将目标对象传递给目标函数
     */
    public double overdraftCharge(Account account) {
        double result;
        if (isPremium()) {
            result = 10;
            if (account._daysOverdrawn > 7) {
                result += (account._daysOverdrawn - 7) * 0.85;
            }
        } else {
            result = account._daysOverdrawn * 1.75;
        }
        return result;
    }
}
